var mProto = {
    builder:{},
    protoName : {},
    EntityType: {},

    initProtoTypes: function () {
        // for (var key in P) {
        //     var strNewKey = P[key].toString();
        //     if (ProtoTypes[strNewKey] == null) {
        //         //ProtoTypes[strNewKey] = key.slice(4);
        //         ProtoTypes[strNewKey] = key + "_MSG";
        //     } else {
        //         ProtoTypes[strNewKey] = key + "_MSG";
        //     }
        // }
        //cc.log("get proto types +++++", ProtoTypes.length);
    },

    // EntityType: {},
    init: function (type, builder) {
        mProto.protoName[type] = type;
        mProto.builder[type] = builder;
        builder.build("G2.Protocol.EntityType");
        if(builder.result && builder.result[type] && builder.result[type].BCMSG){
            var msgs = builder.result[type].BCMSG
            P[type] = {};
            ProtoTypes[type] = {};
            for(var key in msgs){
                P[type][key] = msgs[key];
                ProtoTypes[type][msgs[key]] = key + "_MSG";
            }
            // console.log(P);
            // console.log(ProtoTypes);
        }else{
            cc.error("加载protobuf失败，未找到对应协议ID");
        }

    },
    initCommonModule: function (id) {
        this.EntityType = mProto.builder[id].build("G2.Protocol.EntityType");
    }
};
mProto.protoName = {};
var ProtoTypes = {};

